#pragma once
#include <nice2d/spritedecorator.h>
#include <nice2d/anchor.h>

class SpriteImageDecorator : public SpriteDecorator,public Anchor
{
    DECLARE_OBJECT(SpriteImageDecorator)
public:
    SpriteImageDecorator();
    virtual ~SpriteImageDecorator();
public:
    void setImage(const std::string &file, const sf::IntRect &area);

    void setColor(const sf::Color &color);
    sf::Color getColor()const;

    void setScale(float scale);
    float getScale()const;

    void draw(sf::RenderTarget &target, sf::RenderStates states)const override;
    void update() override;
public:
    PTree serialize()override;
    void deserialize(const PTree &node)override;

    void updateAnchor()override;
private:
    std::unique_ptr<class SpriteImageDecoratorData> data;
};
